{template header common}
<script type="text/javascript" src="{__ROOT__}statics/js/haidao.validate.js?v={HD_VERSION}"></script>
<link type="text/css" rel="stylesheet" href="{__ROOT__}statics/js/upload/uploader.css?v={HD_VERSION}" />
<script type="text/javascript" src="{__ROOT__}statics/js/upload/uploader.js?v={HD_VERSION}"></script>
	<div class="mui-content">
	<form action="{url('comment/index/add')}" method="post">
	    <ul class="mui-table-view layout-list-common comment-form margin-none">
	    	<li class="mui-table-view-cell">
	    		<a href="{url('goods/index/detail',array('sku_id' => $goods['sku_id']))}" class="mui-navigate-right">
	    			<span class="mui-pull-left margin-right"><img src="{thumb($goods[sku_thumb],128,128)}"></span>
	    			<div class="title margin-small-bottom">
	    				<span>{$goods[sku_name]}</span>
	    			</div>
	    			<span class="text-ellipsis text-gray">{$goods[_sku_spec]}</span>
	    		</a>
	    		<div class="margin-top padding-top border-top">
	    			<span class="mui-btn margin-small-right hd-btn-blue" data-mood="positive">好&nbsp;&nbsp;&nbsp;&nbsp;评</span>
	    			<span class="mui-btn margin-small-right hd-btn-gray" data-mood="neutral">中&nbsp;&nbsp;&nbsp;&nbsp;评</span>
	    			<span class="mui-btn margin-small-right hd-btn-gray" data-mood="negative">差&nbsp;&nbsp;&nbsp;&nbsp;评</span>
	    		</div>
	    		<input type="hidden" name="mood" value="positive">
	    	</li>
	    	<li>
	    		<textarea class="border-none margin-none" name="content" placeholder="发表您的商品评价，与给多人一同分享"></textarea>
	    	</li>
	    </ul>
	    <div class="list-col-10 padding-lr">
	    	<div class="padding-tb border-bottom">
	    		<span class="icon-15 mui-pull-left margin-right"><img src="{SKIN_PATH}statics/images/ico_1.png" /></span>
	    		<span>上传图片完成晒单，最多可以上传十张照片</span>
	    	</div>
	    	<ul class="comment-upload-list padding-top mui-clearfix">
	    		<!--<li><img src="../images/goods1.jpg" /></li>-->
	    		<li><div class="upload"> </div></li>
	    	</ul>
	    </div>
	    <div class="padding">
	    	<input type="hidden" name="tid" value="{$_GET['id']}">
	    	<input type="submit" class="mui-btn full mui-btn-primary" value="发表评论"/>
	    </div>
	</form>
	</div>
	{template footer common}
<script type="text/javascript">
	$('.mui-btn-primary').bind('click',function(){
		var ajax_return = $("form").Validform({
			showAllError:true,
			ajaxPost:true,
			callback:function(ret) {
				if(ret.status == 0) {
					$.tips({
						content:ret.message,
						callback:function() {
							return false;
						}
					});
				} else {
					$.tips({
						content:ret.message,
						callback:function() {
							window.location.href = "<?php echo url('comment/index/index',array('iscomment' => 0))?>";
						}
					});					
				}
			}
		})
	})
	window.onload = function(){
		
		var uploader = WebUploader.create({
	        auto:true,
	        fileNumLimit:10,
	        fileVal:'upfile',
	        // swf文件路径
	        swf: '{__ROOT__}statics/js/upload/uploader.swf',
	        // 文件接收服务端。
	        server: "<?php echo url('attachment/index/upload')?>",
	        // 选择文件的按钮。可选
	        formData:{
	            file : 'upfile',
	            upload_init : '<?php echo $attachment_init ?>'
	        },
	        // 内部根据当前运行是创建，可能是input元素，也可能是flash.
	        pick: {
	            id: '.upload',
	            multiple:true
	        },
	        // 压缩图片大小
	        compress:false,
	        accept:{
	            title: '图片文件',
	            extensions: 'gif,jpg,jpeg,bmp,png',
	            mimeTypes: 'image/*'
	        },
	        chunked: false,
	        chunkSize:1000000,
	        resize: false
	    })
	
	    uploader.onUploadSuccess = function(file, response) {
	    	if(response.status == 1) {
	    		$('.upload').parents('.comment-upload-list').prepend('<li><img src="' + response.result.url + '" /><input type="hidden" name="imgs[]" value="' + response.result.url + '"/><span class="remove">×</span></li>');
	    	} else {
	    		$.tips({content: response.message})
	    		return false;
	    	}
	    }
	    $('.margin-small-right').bind('click',function(){
	    	$this = $(this);
	    	if($this.hasClass('hd-btn-gray')){
	    		$this.addClass('hd-btn-blue').removeClass('hd-btn-gray').siblings().removeClass('hd-btn-blue').addClass('hd-btn-gray');
	    		$('input[name=mood]').val($this.attr('data-mood'));
	    	}
	    });
	    
	    mui(".comment-upload-list").on('tap','.remove',function(){
	    	var li = $(this).parents("li");
	    	$.confirms("是否确认删除？",function(){
	    		li.fadeOut(300,function(){
		    		li.remove();
		    	});
	    	});
	    });
		
	}
    
</script>
